<extend name="Base:main" />
<block name="script">

	<link href="/public/logistics/css/bootstrap.min.css" rel="stylesheet" media="screen">

	<link rel="stylesheet" href="__PUBLIC__/seller/js/uploadify/uploadify.css" />
	<script src="__PUBLIC__/seller/js/uploadify/jquery.uploadify.min.js"></script>
	<link href="__PUBLIC__/seller/js/editor/themes/default/css/umeditor.css" type="text/css" rel="stylesheet">
    <script type="text/javascript" src="__PUBLIC__/seller/js/editor/third-party/template.min.js"></script>
    <script type="text/javascript" charset="utf-8" src="__PUBLIC__/seller/js/editor/umeditor.config.js"></script>
    <script type="text/javascript" charset="utf-8" src="__PUBLIC__/seller/js/editor/umeditor.min.js"></script>
    <script type="text/javascript" src="__PUBLIC__/seller/js/editor/lang/zh-cn/zh-cn.js"></script>
    <script src="__PUBLIC__/seller/js/calendar/WdatePicker.js"></script>
    	<link rel="stylesheet" href="__PUBLIC__/seller/css/validform.css" />
	<script src="__PUBLIC__/seller/js/Validform_v5.3.2.js"></script>
	<script type="text/javascript" src="/public/logistics/js/bootstrap.min.js"></script>
	<style>
		body{ background:#fff }

		#allmap{margin-left: 27%;height:400px;width:60%;}
		#r-result{width:100%; font-size:14px;}
	</style>
	<script type="text/javascript" src="http://api.map.baidu.com/api?v=2.0&ak=SC1n3KjGW9rYZGs5tPqpE7dKQnwfcSU9"></script>
</block>
<block name="content">
    <div class="tpl-content-wrapper">
            <div class="tpl-content-page-title">
                发布物流单
            </div>
            <ol class="am-breadcrumb">
                <li><a href="#" class="am-icon-home">首页</a></li>
                <li class="am-active">发布物流单</li>
            </ol>
            <div class="tpl-portlet-components">
                <div class="portlet-title">
                      <div class="caption font-green bold">
                        <span class="am-icon-code"></span>添加
                    </div>
                </div>

	<div class="tpl-block ">
		<div class="am-g tpl-amazeui-form">
			<div class="am-u-sm-12 am-u-md-9">
				<form class="am-form am-form-horizontal" request_type="parent" action="" name="myfromSubmit" method="post">
					<div class="am-form-group">
						<label class="am-u-sm-3 am-form-label">订单号</label>
						<div class="am-u-sm-9">
							<span><input type="text" datatype="*" readonly="readonly"  name="ref" value="{$info.ref}" placeholder="订单号"></span>
						</div>
					</div>
					<div class="am-form-group">
						<label class="am-u-sm-3 am-form-label">收货人</label>
						<div class="am-u-sm-9">
							<span><input type="text" datatype="*"  name="contacts" value="{$info.contacts}" placeholder="收货人"></span>
							<span><small>例如：xxx</small></span>
						</div>
					</div>
					<div class="am-form-group">
						<label class="am-u-sm-3 am-form-label">电话</label>
						<div class="am-u-sm-9">
							<input type="text" datatype="*" value="{$info.mobile}" name="mobile" placeholder="电话">
						</div>
					</div>
					  <div class="am-form-group">
						<label class="am-u-sm-3 am-form-label">重量</label>
						<div class="am-u-sm-9">
							<input type="text" datatype="*" id="weight" name="weight" type="hidden" value="{$info.weight}">
						</div>
					</div>
					<div class="am-form-group">
						<label class="am-u-sm-3 am-form-label">体积</label>
						<div class="am-u-sm-9">
							<input type="text" datatype="*" id="volume" name="volume" type="hidden" value="{$info.volume}">
						</div>
					</div>
					<div class="am-form-group">
						<label class="am-u-sm-3 am-form-label">物流预算</label>
						<div class="am-u-sm-9">
							<input type="text" datatype="*" id="price" name="price" type="hidden" value="{$info.price}">
						</div>
					</div>
					<div class="am-form-group">
						<label class="am-u-sm-3 am-form-label">需求名称</label>
						<div class="am-u-sm-9">
							<input type="text" datatype="*" id="name" name="name" type="hidden" value="{$info.name}">
						</div>
					</div>
					<div class="am-form-group">
						<label class="am-u-sm-3 am-form-label">简介</label>
						<div class="am-u-sm-9">
							<input type="text" datatype="*" id="brief" name="brief" type="hidden" value="{$info.brief}">
						</div>
					</div>
					<div class="am-form-group">
						<label class="am-u-sm-3 am-form-label">是否托管</label>
						<div class="am-u-sm-9">
							<input id="r1" type="radio" value="1" name="type" >是</input>
							<input id="r2" type="radio" value="0" name="type" checked>否</input>
						</div>
					</div>
					<div class="am-form-group">
						<label class="am-u-sm-3 am-form-label">需求发货时间</label>
						<div class="am-u-sm-9">
							<input type="text" datatype="*" id="send_start_time" name="send_start_time" type="hidden" value="{$info.send_start_time}">
						</div>
					</div>
					<div class="am-form-group">
						<label class="am-u-sm-3 am-form-label">截止送达时间</label>
						<div class="am-u-sm-9">
							<input type="text" datatype="*" id="send_end_time" name="send_end_time" type="hidden" value="{$info.send_end_time}">
						</div>
					</div>
					<div class="am-form-group">
						<label class="am-u-sm-3 am-form-label">需求结束时间</label>
						<div class="am-u-sm-9">
							<input type="text" datatype="*" id="end_time" name="end_time" type="hidden" value="{$info.end_time}">
						</div>
					</div>
					<div class="am-form-group city_select_plug">
						<label class="am-u-sm-3 am-form-label" for="optionsCheckbox2">地区</label>
						<div class="col-lg-3" style="width: 25%;">
							<select class="form-control" datatype="*" nullmsg="请选择省" name="province_id" id="province_select" data-value="{$info['province_id']}">
								<option value="">省</option>
							</select>
						</div>
						<div class="col-lg-3" style="width: 25%;">
							<select class="form-control" datatype="*" nullmsg="请选择市" name="city_id" id="city_select" data-value="{$info['city_id']}">
								<option value="">市</option>
							</select>
						</div>
						<div class="col-lg-3" style="width: 25%;">
							<select class="form-control" datatype="*" nullmsg="请选择区" name="area_id" id="area_select" data-value="{$info['area_id']}">
								<option value="">区</option>
							</select>
						</div>
					</div>
					<div class="am-form-group">
						<label class="am-u-sm-3 am-form-label">详细地址</label>
						<div class="col-lg-9">
							<input class="form-control" datatype="*" value="{$info['address']}" nullmsg="详细地址不能为空" name="address" type="text">
						</div>
					</div>
					<div class="am-form-group">
						<label class="am-u-sm-3 am-form-label">&nbsp;</label>
						<div class="col-lg-9" style="margin-left: 5.5%;">
							<div style="width:100%; height:300px; border:1px solid #ccc;" id="allmap"></div>
						</div>
					</div>
					<div class="am-form-group">
						<label class="am-u-sm-3 am-form-label">定位坐标</label>
						<div class="col-lg-4">
							<input class="form-control" readonly name="lng" datatype="*" nullmsg="请选择经纬度" style="background:#efefef" value="{$info['lng']}" id="lng" placeholder="经度" type="text">
						</div>
						<div class="col-lg-4">
							<input class="form-control" readonly name="lat" datatype="*" nullmsg="请选择经纬度" style="background:#efefef" value="{$info['lat']}" id="lat" placeholder="纬度" type="text">
						</div>
					</div>
					<div class="am-form-group">
						<div class="am-u-sm-9 am-u-sm-push-3">
							<input type="hidden" value="{$info.id}" name="id" />
							<button type="submit" class="am-btn am-btn-primary"><notempty name="info">确认修改<else/>确认添加</notempty></button>
						</div>
					</div>
				</form>
                             </div>
                   </div>
           </div>

</div>

		<script type="text/javascript">

            /** 下拉城市三级联动 **/
            if( $("select#province_select").length >= 1 ) {
                $.post("/seller.php/express/area.html" , function(data){
                    var area_data = data.info;
                    $("select#province_select").each(function(){
                        var _self = $(this).closest(".city_select_plug");
                        var htmlStr = '<option value="">省</option>';
                        var province_value = parseInt( _self.find("#province_select").attr("data-value") );
                        var city_value = parseInt( _self.find("#city_select").attr("data-value") );
                        var area_value = parseInt( _self.find("#area_select").attr("data-value") );
                        $.each(area_data , function(k , v){
                            htmlStr += '<option value="'+v.id+'" ';
                            if( province_value > 0 && v.id == province_value ){
                                htmlStr += ' selected ';
                            }
                            htmlStr += '>'+v.name+'</option>';
                        });
                        _self.find("#province_select").html(htmlStr);
                        if( city_value > 0 ) {
                            htmlStr = '<option value="">市</option>';
                            $.each(area_data , function(k , v){
                                if( v.id == province_value ){
                                    $.each(v.sub , function(k1 , v1){
                                        htmlStr += '<option data-pid="'+province_value+'" value="'+v1.id+'" ';
                                        if( city_value > 0 && v1.id == city_value ){
                                            htmlStr += ' selected ';
                                        }
                                        htmlStr += '>'+v1.name+'</option>';
                                    });
                                }
                            });
                            _self.find("#city_select").html(htmlStr);
                        }
                        if( area_value > 0 ) {
                            htmlStr = '<option value="">区</option>';
                            $.each(area_data , function(k , v){
                                if( v.id == province_value ){
                                    $.each(v.sub , function(k1 , v1){
                                        if( v1.id == city_value ) {
                                            $.each(v1.sub , function(k2 , v2){
                                                htmlStr += '<option value="'+v2.id+'" ';
                                                if( area_value > 0 && v2.id == area_value ){
                                                    htmlStr += ' selected ';
                                                }
                                                htmlStr += '>'+v2.name+'</option>';
                                            });
                                        }

                                    });
                                }
                            });
                            _self.find("#area_select").html(htmlStr);
                        }
                        _self.find("#province_select").change(function(){
                            htmlStr = '<option value="">市</option>';
                            var province_id = $(this).val();
                            if( province_id == 0 ) {
                                _self.find("#city_select").html('<option value="">市</option>');
                            } else {
                                $.each(area_data , function(k,v){
                                    if( v.id == province_id ) {
                                        $.each( v.sub , function(k1,v1){
                                            htmlStr += '<option data-pid="'+v1.parent_id+' "value="'+v1.id+'">'+v1.name+'</option>';
                                        });
                                    }
                                });
                                _self.find("#city_select").html(htmlStr);
                            }
                            _self.find("#area_select").html('<option value="">区</option>');
                        });
                        _self.find("#city_select").change(function(){
                            htmlStr = '<option value="">区</option>';
                            var city_id = $(this).val();
                            if( city_id == 0 ) {
                                _self.find("#area_select").html('<option value="">区</option>');
                            } else {
                                var pid = parseInt( _self.find("#city_select option:selected").attr("data-pid") );
                                $.each(area_data , function(k,v){
                                    if( v.id == pid ) {
                                        $.each( v.sub , function(k1,v1){
                                            if( v1.id == city_id ) {
                                                $.each( v1.sub , function(k2,v2){
                                                    htmlStr += '<option value="'+v2.id+'">'+v2.name+'</option>';
                                                });
                                            }
                                        });
                                    }
                                });
                                _self.find("#area_select").html(htmlStr);
                            }
                        });

                    });
                },'json');
            }
            // ====================================================================

            var map = new BMap.Map("allmap");
            $(function(){
                var lng = $("#lng").val();
                var lat = $("#lat").val();
                var point = new BMap.Point(lng,lat);
                map.centerAndZoom(point,11);
                bImg(lng,lat);
            });
            setTimeout(function(){
                map.setZoom(14);
            }, 2000);  //2秒后放大到14级

            map.enableScrollWheelZoom(true);
            map.addEventListener("click", showInfo);
            function showInfo(e){
                $("#lng").val(e.point.lng);
                $("#lat").val(e.point.lat);
                bImg(e.point.lng,e.point.lat)
            }
            function bImg(lng,lat){
                var point = new BMap.Point(lng,lat);
                map.clearOverlays();
                var marker = new BMap.Marker(point);
                map.addOverlay(marker);
                marker.setAnimation(BMAP_ANIMATION_BOUNCE);
            }
            $(".city_select_plug select").change(function(){
                var city_data = '';
                var index_num = $(this).parent().index();
                $(".city_select_plug select").each(function(k){
                    var selct_txt = $(this).find('option:selected').text();
                    if( selct_txt != '省' && selct_txt != '市' && selct_txt != '区' && k < index_num) {
                        city_data += selct_txt;
                    }
                });
                map.centerAndZoom(city_data,(index_num == 1 ? 11 : ( index_num == 2 ? 12 : 15)));
            });
		</script>
</block>